package com.appcenter.autotask.jobs;

import com.appcenter.autotask.config.RemoteProperties;
import com.appcenter.autotask.service.BaseJob;
import com.appcenter.autotask.service.HttpAPIService;
import com.appcenter.jz.config.HttpResult;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.Date;


@EnableConfigurationProperties(RemoteProperties.class)
public class DataSynchronizeJob implements BaseJob {
    @Autowired
    private HttpAPIService httpAPIService;
    @Autowired
    ObjectMapper objectMapper;

    @Autowired
    RemoteProperties remoteProperties;
    private static Logger log = LoggerFactory.getLogger(DataSynchronizeJob.class);
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {

        System.out.print("开始执行同步数据操作----"+new Date());
        String GetAppsUrl = remoteProperties.getDataSynchronize() + "/datasynchronize";
        String responseJson = httpAPIService.JsonSMS(GetAppsUrl, "{}");
        System.out.print("同步数据操作已经结束----"+new Date());

        log.info("DataSynchronizeJob执行时间: " + responseJson+"------"+context.getJobDetail().getKey());
    }
}
